﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QLCH_ANUONG.Forms
{
    public partial class frmDangNhap : Form
    {
        public frmDangNhap()
        {
            InitializeComponent();
        }

        private void butDangNhap_Click(object sender, EventArgs e)
        {
            EnterDangNhap();
        }
        private void EnterDangNhap()
        {
            string strSQL = "";
            string strUser = txtUser.Text;
            string strPassword = txtPassword.Text;
            strSQL = "select code from Users where data= " + "'" + strUser + "' and Matkhau ='" + strPassword + "'";
            ADODB.Recordset Rs = new ADODB.Recordset();
            Rs.Open(strSQL, clsMain.flexConn.fcConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, -1);
            if (Rs.RecordCount > 0)
            {
                clsMain.booLogin = true;
                clsMain.strUserLogin = Convert.ToString(Rs.Fields[0].Value);
                this.Close();
            }
        }
        private void butThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmDangNhap_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.Equals(System.Windows.Forms.Keys.Enter))
            {
                EnterDangNhap();
            }
        }


    }
}
